package com.ifreeee.springview.rename;

import java.io.File;

public class Rename {

    private static final String ROOT_DIR_STR = "D:/CloudMusic/电台节目";

    public static void main(String[] args) throws Exception {

        File rootDir = new File(ROOT_DIR_STR);

        File[] files = rootDir.listFiles((d, name) -> {
            return name.indexOf("(1)") > -1
                    || name.indexOf("(2)") > -1
                    || name.indexOf("(3)") > -1;
        });

        for (File file : files) {
            String absolutePath = file.getAbsolutePath();
            absolutePath = absolutePath.replaceAll("\\(1\\)", "");
            absolutePath = absolutePath.replaceAll("\\(2\\)", "");
            absolutePath = absolutePath.replaceAll("\\(3\\)", "");
            File newFile = new File(absolutePath);
//            System.out.println(file.getAbsolutePath() + "\t" + newFile.getAbsolutePath());
            boolean b = file.renameTo(newFile);
            System.out.println(b);
        }



    }
}
